
<%@ page import="comptadub.Presence" %>
<html>
    <head>
        <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
        <meta name="layout" content="main" />
        <title><g:message code="presence.create.label" /></title>
    </head>

    <body>
        <div class="nav">
            <span class="menuButton"><a class="home" href="${createLink(uri: '/')}"><g:message code="default.home.label"/></a></span>
            <span class="menuButton"><g:link class="list" action="list"><g:message code="presence.list.label" /></g:link></span>
        </div>

        <div class="body">
            <h1><g:message code="presence.create.label" /></h1>

            <g:if test="${flash.message}">
            <div class="message">${flash.message}</div>
            </g:if>

            <g:hasErrors bean="${presenceInstance}">
            <div class="errors">
                <g:renderErrors bean="${presenceInstance}" as="list" />
            </div>
            </g:hasErrors>
            
            <g:form action="save" method="post" >
                <div class="dialog">
                    <table>
                        <tbody>
                            <g:if test="${session?.typeMembre == 'admin'}"
                            <tr class="prop">
                                <td valign="top" class="name">
                                    <label for="membre"><g:message code="presence.membre.label" default="Membre" /></label>
                                </td>
                                <td valign="top" class="value ${hasErrors(bean: presenceInstance, field: 'membre', 'errors')}">
                                    <g:select name="membre.id" from="${comptadub.Membre.list()}" optionKey="id" optionValue="nom" value="${presenceInstance?.membre?.id}"  />
                                </td>
                            </tr>
                            </g:if>
                            <g:else>
                                <g:hiddenField name="membre.id" value="${session?.idMembre}" />
                            </g:else>

                            <tr class="prop">
                                <td valign="top" class="name">
                                    <label for="nbPersonne"><g:message code="presence.nbPersonne.label" default="Nb personnes" /></label>
                                </td>
                                <td valign="top" class="value ${hasErrors(bean: presenceInstance, field: 'nbPersonne', 'errors')}">
                                    <g:textField name="nbPersonne" value="${fieldValue(bean: presenceInstance, field: 'nbPersonne')}" />
                                </td>
                            </tr>

                            <tr class="prop">
                                <td valign="top" class="name">
                                    <label for="nbEnfant"><g:message code="presence.nbEnfant.label" default="Nb enfants (6-12 ans)" /></label>
                                </td>
                                <td valign="top" class="value ${hasErrors(bean: presenceInstance, field: 'nbEnfant', 'errors')}">
                                    <g:textField name="nbEnfant" value="${fieldValue(bean: presenceInstance, field: 'nbEnfant')}" />
                                </td>
                            </tr>

                            <tr class="prop">
                                <td valign="top" class="name">
                                    <label for="nbGratuit"><g:message code="presence.nbGratuit.label" default="Nb gratuits (travaux ou enfants -6ans)" /></label>
                                </td>
                                <td valign="top" class="value ${hasErrors(bean: presenceInstance, field: 'nbGratuit', 'errors')}">
                                    <g:textField name="nbGratuit" value="${fieldValue(bean: presenceInstance, field: 'nbGratuit')}" />
                                </td>
                            </tr>
                        
                            <tr class="prop">
                                <td valign="top" class="name">
                                    <label for="dateArrivee"><g:message code="presence.dateArrivee.label" default="Arrivée" /></label>
                                </td>
                                <td valign="top" class="value ${hasErrors(bean: presenceInstance, field: 'dateArrivee', 'errors')}">
                                    <g:datePicker name="dateArrivee" precision="hour" value="${presenceInstance?.dateArrivee}" years="${2010..2020}"  />
                                </td>
                            </tr>
                        
                            <tr class="prop">
                                <td valign="top" class="name">
                                    <label for="dateDepart"><g:message code="presence.dateDepart.label" default="Départ" /></label>
                                </td>
                                <td valign="top" class="value ${hasErrors(bean: presenceInstance, field: 'dateDepart', 'errors')}">
                                    <g:datePicker name="dateDepart" precision="hour" value="${presenceInstance?.dateDepart}" years="${2010..2020}" />
                                </td>
                            </tr>               

                            <tr class="prop">
                                <td valign="top" class="name">
                                    <label for="commentaire"><g:message code="presence.commentaire.label" default="Commentaire" /></label>
                                </td>
                                <td valign="top" class="value ${hasErrors(bean: presenceInstance, field: 'commentaire', 'errors')}">
                                    <g:textArea name="commentaire" cols="40" rows="5" value="${presenceInstance?.commentaire}" />
                                </td>
                            </tr>
                        </tbody>
                    </table>
                </div>

                <div class="buttons">
                    <span class="button"><g:submitButton name="create" class="save" value="${message(code: 'default.button.create.label', default: 'Create')}" /></span>
                </div>
            </g:form>
        </div>
    </body>
</html>
